<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>手机号归属地查询</title>
    <style>
        /* 基础样式 - 类似Bootstrap风格 */
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            line-height: 1.5;
            color: #212529;
            background-color: #f8f9fa;
            padding: 20px;
        }

        .container {
            max-width: 600px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
        }

        .form-group {
            margin-bottom: 1rem;
        }

        .form-control {
            display: block;
            width: 95%;
            padding: 0.375rem 0.75rem;
            font-size: 1rem;
            line-height: 1.5;
            color: #495057;
            background-color: #fff;
            background-clip: padding-box;
            border: 1px solid #ced4da;
            border-radius: 0.25rem;
            transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
        }

        .form-control:focus {
            color: #495057;
            background-color: #fff;
            border-color: #80bdff;
            outline: 0;
            box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
        }

        .result-container {
            margin-top: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 5px;
        }

        .result-item {
            display: flex;
            margin-bottom: 10px;
        }

        .result-label {
            font-weight: bold;
            min-width: 80px;
            color: #6c757d;
        }

        .result-value {
            color: #212529;
        }

        .title {
            font-size: 1.5rem;
            margin-bottom: 20px;
            color: #343a40;
            text-align: center;
        }
    </style>
    <script src="lib/jQuery/jquery-3.7.1.js"></script>
    <script>
        function query(event) {
            if (event.keyCode === 13) {
                // 回车键
                // 发请求
                console.log(event.target.value)
                $.get("phone/" + event.target.value, function (result) {
                    if (result.code === 500) {
                        alert(result.msg)
                        return
                    }
                    if (result.code === "200000") {
                        let data = result.data
                        $('#area').text(data.province + ' ' + data.city)
                        $('#yunyingshang').text(data.isp)
                    } else {
                        alert(result.message)
                    }
                })
            }
        }
    </script>
</head>
<body>
<div class="container">
    <h2 class="title">手机号归属地查询</h2>

    <div class="form-group">
        <!-- onkeyup是按键弹上来时触发 -->
        <input type="text" class="form-control"
               id="phone" placeholder="请输入手机号" onkeyup="query(event)"/>
    </div>

    <div class="result-container">
        <div class="result-item">
            <span class="result-label">归属地：</span>
            <span class="result-value" id="area">未查询</span>
        </div>
        <div class="result-item">
            <span class="result-label">运营商：</span>
            <span class="result-value" id="yunyingshang">未查询</span>
        </div>
    </div>
</div>
</body>
</html>